package com.blink.optimize.apis.variable;

import org.junit.jupiter.api.Test;

/**
 * <ClassName>TestVariableCompare</ClassName>
 * <Description></Description>
 *
 * @Author liuxianzhao
 * @Date 2018年01月06日 12:33
 */
public class TestVariableCompare {
    public static int b = 0;

    /**
     * 局部变量
     */
    @Test
    public void testLocalVariable() {
        int a = 0;
        long start1 = System.nanoTime();
        for (int i = 0; i < 1000000000; i++) {
            a++;
        }
        System.out.println(System.nanoTime() - start1);
    }

    /**
     * 静态变量
     */
    @Test
    public void testGlobalVariable() {
        long start2 = System.nanoTime();
        for (int i = 0; i < 1000000000; i++) {
            b++;
        }
        System.out.println(System.nanoTime() - start2);
    }

}
